package practise.alogrithm.introductionToAlogrithm;


/**
 * Created by richard on 6/2/14.
 */
public class LinkedListBuilder {
    public static <T> ListNode<T> buildLinkedListFromArray(T[] number){
       ListNode<T> listNode = new ListNode();
        listNode.setValue(number[0]);
        ListNode<T> head = new ListNode();
        head= listNode;
        for(int i =1; i<number.length;i++){
            listNode.setNext(new ListNode<T>());
            listNode = listNode.getNext();
            listNode.setValue(number[i]);

        }
        return head;
    }

    public static void swap(int[] array, int target, int source){
        int temp =array[target];
        array[target]=array[source];
        array[source]=temp;
    }
}
